package main;

import entity.Student;
import org.junit.Test;
import service.impl.StudentServiceImpl;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/*
杨威
2021/9/7
12:43
*/
public class StudentTest {

    @Test
    public void testDelete(){
        StudentServiceImpl studentService = new StudentServiceImpl();
        int i = studentService.deleteByStuId(22);
        System.out.println("i = " + i);
    }
    @Test
    public void testInsert(){
        StudentServiceImpl studentService=new StudentServiceImpl();
        try {
            Date parse=new SimpleDateFormat("yyyy-mm-dd").parse("1995-03-6");
            Student student = new Student(0,"李四", "男", "12278926769",parse,"zhangsanvip@qq.com","上海市宝坻区" , 1);
            studentService.addStudentIfo(student);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    @Test
    public void testSelectOne(){
        StudentServiceImpl studentService=new StudentServiceImpl();
        List<Student> students = studentService.selectByStuId(6);
        Student student = students.get(0);
        System.out.println("student = " + student);
    }
    @Test
    public void testSelectAll(){
        StudentServiceImpl studentService=new StudentServiceImpl();
        List<Student> students = studentService.showAllStudent();
        students.forEach(System.out::println);
    }
}
